package cn.zyb.feignClient;

import cn.zyb.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component // 必须交给spring管理
public class UserFeignClientFallbackFactory implements FallbackFactory<UserFeignClient> {

    /**
     * 此方法就是工厂帮助我们创建拖地类的方法
     * @param throwable
     * @return
     */
    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient() {
            @Override
            public User getById(Long id) {
                return new User(-1L, "触发熔断", "服务不可以，请稍后重试！");
            }
        };
    }

}
